<?php

	class DBIO
	{

		/*
		** Checks to see if a user is in the DB
		*/
		public function IsUserInDB($email)
		{			
			$DBConnector = new DBAccess();
		
			$dblink = $DBConnector->DBConnect();
			
			$result = $DBConnector->RunSQL("SELECT Email FROM UserIdentity WHERE Email LIKE '" . $email . "'");
		
			$numrecords = count($result);
						
			if($numrecords > 0)
			{
				return true;	
			}else
			{
				return false;	
			}
			
		}
		
		/*
		** Add a new user tothe DB
		*/
		public function AddUserToDB($email, $identity)
		{
			$DBConnector = new DBAccess();
		
			$dblink = $DBConnector->DBConnect();
			
			$result = $DBConnector->RunSQL("INSERT INTO UserIdentity (Email, OpenID, AuthToken, TokenValid) VALUES ('" . $email . "','" . $identity . "','','')");
		
			
		}
		
		public function AddTokenToDB($email, $token)
		{
			$DBConnector = new DBAccess();
		
			$dblink = $DBConnector->DBConnect();
			
			$result = $DBConnector->RunSQL("UPDATE UserIdentity SET AuthToken = '" . $token . "', TokenValid='true' WHERE Email LIKE '" . $email . "'");

		}
		
		
	}



?>